home *** CD-ROM | disk | FTP | other *** search
- #ifndef (MENGER_DEPTH)
- #declare MENGER_DEPTH = 2
- #end
-
- #ifndef (MENGER_SHAPE)
- #declare MENGER_SHAPE =
- box {
- <-0.5, -0.5, -0.5>, <0.5, 0.5, 0.5>
- }
- #end
-
- #ifndef (MENGER_SUBSHAPE)
- #declare MENGER_SUBSHAPE =
- box {
- <-0.55, -0.5, -0.5>, <0.55, 0.5, 0.5>
- }
- #end
-
-
-
- #declare MENGER_TMPDEPTH = MENGER_DEPTH
-
- #declare MENGER_OBJECT =
- difference {
- object { MENGER_SHAPE }
-
- #declare MENGER_PARTS = 0
- #while (MENGER_TMPDEPTH>=0)
- #declare MENGER_ROWS = pow(3,MENGER_TMPDEPTH)
- #declare MENGER_COLS = MENGER_ROWS
- #declare MENGER_SCALE = pow(3,-(MENGER_TMPDEPTH+1))
- #declare MENGER_SCALE2 = pow(3,-(MENGER_TMPDEPTH))
- #declare MENGER_SUB =
- object { MENGER_SUBSHAPE scale <1, MENGER_SCALE, MENGER_SCALE> }
-
- #while (MENGER_ROWS>0)
- #declare MENGER_COLS = pow(3,MENGER_TMPDEPTH)
- #while (MENGER_COLS>0)
- object {
- MENGER_SUB
- rotate <0, 90, 0>
- translate <(MENGER_COLS-0.5)*MENGER_SCALE2-0.5, (MENGER_ROWS-0.5)*MENGER_SCALE2-0.5, 0>
- }
- object {
- MENGER_SUB
- rotate <0, 90, 0>
- translate <(MENGER_COLS-0.5)*MENGER_SCALE2-0.5, (MENGER_ROWS-0.5)*MENGER_SCALE2-0.5, 0>
- rotate <0, 90, 0>
- }
- object {
- MENGER_SUB
- rotate <0, 90, 0>
- translate <(MENGER_COLS-0.5)*MENGER_SCALE2-0.5, (MENGER_ROWS-0.5)*MENGER_SCALE2-0.5, 0>
- rotate <90, 0, 0>
- }
- #declare MENGER_COLS = MENGER_COLS-1
- #end
- #declare MENGER_ROWS = MENGER_ROWS-1
- #declare MENGER_PARTS = MENGER_PARTS+3
- #end
-
- #declare MENGER_TMPDEPTH = MENGER_TMPDEPTH-1
- #end
- }
-